﻿using System;
using System.IO;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

// Token: 0x020003AB RID: 939
public class ModalInput : ModalUI
{
	// Token: 0x06001762 RID: 5986 RVA: 0x0009BCD0 File Offset: 0x00099ED0
	protected override void Awake()
	{
		base.Awake();
		this.enterButton.onClick.AddListener(new UnityAction(this.Enter));
		this.cancelButton.onClick.AddListener(new UnityAction(this.Cancel));
	}

	// Token: 0x06001763 RID: 5987 RVA: 0x0009BD10 File Offset: 0x00099F10
	private void Update()
	{
		this.enterButton.interactable = (this.enableBlank || this.input.text.Length > 0);
	}

	// Token: 0x06001764 RID: 5988 RVA: 0x0009BD40 File Offset: 0x00099F40
	private void Enter()
	{
		if (!this.enableBlank && this.input.text.Length == 0)
		{
			return;
		}
		if (this.enterSE != null)
		{
			this.GameCtrl.audioCtrl.Play2DSE(this.enterSE);
		}
		if (this.enterAct != null)
		{
			this.enterAct(this.input.text);
		}
		base.End();
	}

	// Token: 0x06001765 RID: 5989 RVA: 0x0009BDBC File Offset: 0x00099FBC
	private void Cancel()
	{
		if (this.cancelSE != null)
		{
			this.GameCtrl.audioCtrl.Play2DSE(this.cancelSE);
		}
		if (this.cancelAct != null)
		{
			this.cancelAct();
		}
		base.End();
	}

	// Token: 0x06001766 RID: 5990 RVA: 0x0009BE0C File Offset: 0x0009A00C
	public void SetUp(bool isFileName, string text, Action<string> enterAct, Action cancelAct, bool enableBlank, string def)
	{
		this.isFileName = isFileName;
		this.text.text = text;
		this.enterAct = enterAct;
		this.cancelAct = cancelAct;
		this.enableBlank = enableBlank;
		this.input.text = def;
	}

	// Token: 0x06001767 RID: 5991 RVA: 0x0009BE48 File Offset: 0x0009A048
	public void InputString(string str)
	{
		if (!this.invoke)
		{
			return;
		}
		if (this.isFileName)
		{
			this.CheckFileName();
		}
	}

	// Token: 0x06001768 RID: 5992 RVA: 0x0009BE68 File Offset: 0x0009A068
	private void CheckFileName()
	{
		if (!this.isFileName)
		{
			return;
		}
		string text = this.input.text;
		char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
		foreach (char c in invalidFileNameChars)
		{
			text = text.Replace(c.ToString(), string.Empty);
		}
		this.invoke = false;
		this.input.text = text;
		this.invoke = true;
	}

	// Token: 0x04001B0B RID: 6923
	public Canvas myCanvas;

	// Token: 0x04001B0C RID: 6924
	public Text text;

	// Token: 0x04001B0D RID: 6925
	public InputField input;

	// Token: 0x04001B0E RID: 6926
	public Button enterButton;

	// Token: 0x04001B0F RID: 6927
	public Button cancelButton;

	// Token: 0x04001B10 RID: 6928
	private Action<string> enterAct;

	// Token: 0x04001B11 RID: 6929
	private Action cancelAct;

	// Token: 0x04001B12 RID: 6930
	public AudioClip enterSE;

	// Token: 0x04001B13 RID: 6931
	public AudioClip cancelSE;

	// Token: 0x04001B14 RID: 6932
	private bool isFileName;

	// Token: 0x04001B15 RID: 6933
	private bool invoke = true;

	// Token: 0x04001B16 RID: 6934
	private bool enableBlank;
}
